#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: api18_javascript_function.py 
@version:
@time: 2022/06/21 
"""
from TapClientCore.T02_tm_api.v2_api.v2_api_base import *


class Api18JavaScriptFunctionUrl(V2ApiUrlBase):
    url_javascript_function = api_joint(
        V2ApiUrlBase().server, 'Javascript_functions'
    )


class Api18JavaScriptFunction(V2ApiBase, Api18JavaScriptFunctionUrl):

    # 获取 func
    def get_javascript_function(self, _filter):
        response = self.tapclient(
            self.get,
            self.url_javascript_function
            + self.access_token
            + self.filter(_filter)
        )
        return response

    # 创建 func
    def post_javascript_function(self, payload):
        response = self.tapclient(
            self.post,
            self.url_javascript_function
            + self.access_token,
            json=payload
        )
        return response

    # 更新 func
    def patch_javascript_function(self, payload):
        response = self.tapclient(
            self.patch,
            self.url_javascript_function
            + self.access_token,
            json=payload
        )
        return response

    # 删除func
    def delete_javascript_function(self, fun_id):
        response = self.tapclient(
            self.delete,
            api_joint(
                self.url_javascript_function,
                fun_id
            )
            + self.access_token
        )
        return response
